<script type="text/javascript">
    $(function() {
        $.fn.dataGridOptions.formSubFun("#form",'/coupon/doAppend.html',"添加成功！","添加失败！");
    });
</script> 
<form id="form"  method="post">
<div class="popForm sForm">
    <input type="hidden" name="category" id="category" value="${coupon.category}">
    <div class="formitm">
        <label class="lab">红包名称：</label>
        <div class="ipt"><input type="text" id="categoryName" name="name" class="easyui-validatebox validatebox-text" data-options="required: true"></div>
    </div>
    <div class="formitm">
        <label class="lab">红包种类：</label>
        <div class="ipt">
            <select name="code" id="type">
                <option value="1">用户注册</option>
                <option value="2">实名认证</option>
                <!-- <option value="3">充值</option><option value="4">投资</option> -->
                <option value="5">邀请好友</option>
                <option value="6">VIP升级</option>
                <option value="7">首次充值</option>
                <option value="8">首次投资</option>
                
            </select>
        </div>
    </div>
    <div class="formitm">
        <label class="lab">启用：</label>
        <div class="ipt"><input type="radio" name="status" value="1" checked="checked">是&nbsp;&nbsp;&nbsp;<input type="radio" name="status" value="2">否</div>
    </div>
    <div class="formitm">
        <label class="lab">发放时间：</label>
        <div class="ipt"><input type="text" name="putStartTime" id="startTime" style="width:90px;" class="easyui-validatebox" data-options="required: true" value="" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',readOnly:true})" placeholder="起始时间"  class="searchTime"/>-
        <input type="text" name="putEndTime" id="endTime" style="width:90px;" class="easyui-validatebox" data-options="required: true" value="" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',readOnly:true})" placeholder="结束时间"  class="searchTime"/></div>
    </div>
    <div class="formitm">
        <label class="lab">有效期：</label>
        <div class="ipt"><input type="text" name="lifecycle" style="width:60px;" value="30">天</div>
    </div>
    <div class="formitm" id="redPacketMoney">
        <label class="lab">金额：</label>
        <div class="ipt"><input type="text" class="easyui-validatebox validatebox-text" id="denomination" name="denomination" style="width:60px;" data-options="required: true">元</div>
    </div>
    <div class="formitm" id="rules" style="display:none;">
        <label class="lab">&nbsp;</label>
        <div class="ipt" id="ruleList">
            <div class="ruleList"><input type="text" name="couponRules[0].minValue" style="width:60px;">≤投标/充值金额&lt;<input type="text" name="couponRules[0].maxValue" style="width:60px;">时，金额<input type="text" name="couponRules[0].maxCount" style="width:60px;">元<a href="javascript:;" class="delRules">删除</a><a href="javascript:;" id="addRules">添加</a></div>
        </div>
    </div>
    
</div>
<script type="text/javascript">

    var typeVal;
    $("#type").change(function(){
        if(typeVal==3 || typeVal == 4 || typeVal ==7 || typeVal == 8){
            $("#rules").show();
            $("#denomination").val("0");
            $("#redPacketMoney").hide();
        }else{
            $("#rules").hide();
            $("#redPacketMoney").show();
        }
    })
    
    var count =1;
    $("#addRules").click(function(){
        var html="";
        html = '<div class="ruleList"><input type="text" name="couponRules['+count+'].minValue" style="width:60px;">≤投标/充值金额&lt;<input type="text" name="couponRules['+count+'].maxValue" style="width:60px;">时，金额<input type="text" name="couponRules['+count+'].maxCount" style="width:60px;">元<a href="javascript:;" class="delRules">删除</a></div>';
        $("#ruleList").append(html);
        count = count + 1;
    })
    
    //--------------------------------删除-------------------
    $("body").on("click",".delRules",function(){
        if($(".ruleList").length  > 1){
            $(this).parent().remove();
        }
    })
    
</script>
</form>
